#pragma once

class AuthClient : public ISocketHandler
{
	static ListenServer* gClientServer;
	static SocketManager<AuthClient>* gClientMgr;
public:
	static void startNetwork();
	static void stopNetwork();

	enum LogonOpcodes
	{
		Challenge = 0,
		Proof = 1,
		ReconnectChallenge = 2,
		ReconnectProof = 3,
		ListRealms = 0x10,
	};

private:
	std::map<uint32, std::function<void (ByteBuffer&)>> mPacketHandlers;
	AuthCrypt mCrypt;
	bool mChlgPassed;

	void notifyDataRead(const std::vector<uint8>& data);

	void handleRealmList(ByteBuffer& data);
public:
	AuthClient();
	void clientConnected(Socket* socket);
};